home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Professional Soft Collection 1.02
/
Professional Soft Collection 1.02.iso
/
winutils
/
wingauge.zip
/
WTIMER.C
< prev
Wrap
C/C++ Source or Header
|
1993-01-19
|
1KB
|
42 lines
#pragma hdrfile "WinGauge.SYM"
#include <win31.h>
#include "wingauge.h"
#include "wingauge.rh"
#pragma hdrstop
#define INTERVAL 5493 // Interval between messages in idle
// system * 100
#define TIMESIZE 20 // Size of array of time intervals
static WORD awTimes[TIMESIZE], // Time interval array
// (initialized to 0 by default)
wSumTimes = 0; // Sum of interval array
static short sCount = -1, // Count of collecting messages
sIndex = 0; // Current time array index
static DWORD lPrevTime; // "Old current" time -- used for
// interval calculating
WORD wmTimer(void)
{ DWORD lTime = GetCurrentTime(); // Current system time
if( sCount < TIMESIZE ) // Have we collected TIMESIZE intvls?
++sCount;
if( sCount == 0 ) // If it is first time...
{ lPrevTime = lTime; // store it and bye
return 0;
}
wSumTimes -= awTimes[sIndex]; // Subtract oldest interval,
wSumTimes += ( awTimes[sIndex] = (WORD)(lTime - lPrevTime) );
// calculate new one,
// store it in interval array
// and add it to total sum.
if( ++sIndex == TIMESIZE ) // Check array index for overflow
sIndex = 0;
lPrevTime = lTime;
return 100 - MyMulDiv( INTERVAL, sCount, wSumTimes );
}